package com.hosever.model;

import java.security.NoSuchAlgorithmException;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Table;

import com.hosever.core.AbstractModel;
import com.hosever.utils.SeverHtmlUtils;
import com.hosever.utils.SeverSecurity;
/**
 * 用户对象
 * @author Sever
 *
 */
@Entity
@Table(name="tbl_user")
public class User extends AbstractModel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8623109652775106626L;
	/**
	 * 用户名
	 */
	private String username;
	/**
	 * 密码
	 */
	private String password;
	/**
	 * 昵称
	 */
	private String nickname;
	/**
	 * 性别
	 */
	private String sex;
	/**
	 * 与站长关系
	 */
	private String relation;
	/**
	 * QQ
	 */
	private String qq;
	/**
	 * e-mail
	 */
	private String email;
	/**
	 * 注册时间
	 */
	private Date registerTime;
	/**
	 * 新消息数
	 */
	private int newMessage;
	/**
	 * 用户状态
	 * 0.无状态 1.被拉黑
	 */
	private int status;
	/**
	 * QQ登录OpenID
	 */
	private String openIdQQ;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = SeverHtmlUtils.htmlSpecialCharFilter(username);
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		try {
			this.password = SeverSecurity.severEncrypt(password);
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = SeverHtmlUtils.htmlSpecialCharFilter(nickname);
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getRelation() {
		return relation;
	}
	public void setRelation(String relation) {
		this.relation = relation;
	}
	public String getQq() {
		return qq;
	}
	public void setQq(String qq) {
		this.qq = SeverHtmlUtils.htmlSpecialCharFilter(qq);
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = SeverHtmlUtils.htmlSpecialCharFilter(email);
	}
	public Date getRegisterTime() {
		return registerTime;
	}
	public void setRegisterTime(Date registerTime) {
		this.registerTime = registerTime;
	}
	public int getNewMessage() {
		return newMessage;
	}
	public void setNewMessage(int newMessage) {
		this.newMessage = newMessage;
	}

	@Override
	public String toString() {
		return "user:"+username+",pwd:"+password;
	}
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getOpenIdQQ() {
		return openIdQQ;
	}

	public void setOpenIdQQ(String openIdQQ) {
		this.openIdQQ = openIdQQ;
	}

}
